#
# Copyright 2024 Kumo.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# below are examples, after initialization, modify it to your own.
###########################################################################
###kmcmake_example
set(KRPC_SRC
        ballot.cc
        ballot_box.cc
        builtin_service_impl.cc
        cli.cc
        cli_service.cc
        closure_queue.cc
        configuration.cc
        configuration_manager.cc
        file_reader.cc
        file_service.cc
        file_system_adaptor.cc
        fsm_caller.cc
        fsync.cc
        lease.cc
        log.cc
        log_entry.cc
        log_manager.cc
        memory_log.cc
        node.cc
        node_manager.cc
        protobuf_file.cc
        raft.cc
        raft_meta.cc
        raft_service.cc
        remote_file_copier.cc
        repeated_timer_task.cc
        replicator.cc
        route_table.cc
        snapshot.cc
        snapshot_executor.cc
        snapshot_throttle.cc
        storage.cc
        util.cc
        )
kmcmake_cc_object(
        NAMESPACE ${PROJECT_NAME}
        NAME raft_object
        SOURCES
        ${KRPC_SRC}
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
)

kmcmake_cc_library(
        NAMESPACE ${PROJECT_NAME}
        NAME kraft
        OBJECTS
        raft_object proto_obj
        DEPS
        proto_obj
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PLINKS
        ${KMCMAKE_DEPS_LINK}
        PUBLIC
)

kmcmake_cc_interface(
        NAMESPACE ${PROJECT_NAME}
        NAME version
        HEADERS
        version.h
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PUBLIC
)

kmcmake_cc_binary(
        NAMESPACE ${PROJECT_NAME}
        NAME kraft_cli
        SOURCES
        tools/kraft_cli.cc
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        DEPS
        ${PROJECT_NAME}::kraft_static
        LINKS
        ${KMCMAKE_DEPS_LINK}
        ${PROJECT_NAME}::kraft_static
        PUBLIC
)

###kmcmake_example